﻿@{
	ViewBag.Title = Resources.Menu_ConferenceManage + ConstValues.strDash + Resources.HuiTongCIS;
}
<div id="menuBar" style="height:35px;">
	<div style="float: left; padding: 5px 5px; font-weight: bold; text-align: left;">
		@Resources.ConferenceName/@Resources.NickName：<input id="conferenceNameSearch" class="easyui-textbox" style="height:27px; width:200px;" />&nbsp;&nbsp;
		<a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" onclick="searchData();">@Resources.Search</a>&nbsp;&nbsp;
	</div>
	<div class="clear"></div>
</div>
<div id="dataGrid"></div>

@section Scripts {
<script>
	$(function () {
		$("#conferenceNameSearch").textbox("textbox").bind("keydown", function (e) {
			if (e.keyCode == 13) {
				searchData();
			}
		});

		$("#dataGrid").datagrid({
			url: "@Url.Action(nameof(ConferenceHomeController.GetData),
					nameof(ConferenceHomeController).GetControllerName())",
			method: "get",
			fitColumns: false,
			width: 1200,
			height: $(window).height() - 110,
			pagination: true,
			nowrap: false,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			singleSelect: true,
			pageSize: 100,
			pageList: [100, 200, 300, 400, 500],
			frozenColumns: [[
				{ field: "id", title: "ID", hidden: true },
				{
					field: "operate", title: "@Resources.Operate", align: "center", width: 150,
					formatter: function (value, rec) {
						if (rec.status == "@ConstValues.Status.正常") {
							return "<a href='#' style='color:#66CDAA;font-weight:bold;text-decoration:underline;' onclick='maintenance(\""
									+ rec.id + "\")'>@Resources.Maintenance</a>"
						} else {
							return "<span style='color:#DC143C;font-weight:bold;'>@Resources.StatusReadyToReview</span>"
						}
					}
				},
				{
					field: "conferenceName", title: "@Resources.ConferenceName", align: "center", sortable: true, width: 300,
					formatter: function (value, rec) {
						var conStr = ""
						if (rec.status == "@ConstValues.Status.正常") {
							if (rec.homePageUrl != null && rec.homePageUrl != "") {
								conStr += "<a href=' "+ rec.homePageUrl +" ' style='color:#1874CD;text-decoration:underline;' target='_blank'>" + value + "</a>  "
							} else {
								var tmp = rec.conferenceNickName == null ? "" : rec.conferenceNickName.replace(new RegExp("'",'g'),"’").replace(new RegExp('"','g'),"“");
								conStr += "<a href='@Url.Action(nameof(MeetingMainController.Index), nameof(MeetingMainController).GetControllerName())"
										+ "/" +tmp +"' style='color:#1874CD;text-decoration:underline;' target='_blank'>" + value + "</a>  ";
							}
						} else {
							conStr += value;
						}
						return conStr;
					}
				},
				{ field: "conferenceNickName", title: "@Resources.ConferenceNickName", align: "center", sortable: true, width: 150 }
			]],
			columns: [[
				{ field: "operateTime", title: "@Resources.OperateTime", align: "center", sortable: true, width: 300 },
				{ field: "operateLocation", title: "@Resources.OperateLocation", align: "center", sortable: true, width: 200 },
				{ field: "conferenceStartDate", title: "@Resources.ConferenceStartDate", align: "center", sortable: true, width: 200 },
				{ field: "conferenceEndDate", title: "@Resources.ConferenceEndDate", align: "center", sortable: true, width: 200 },
				{
					field: "homePageUrl", title: "@Resources.ConferenceHomePageUrl", align: "center", sortable: true, width: 400,
					formatter: function(value, rec) {
						if (value != null && value != "") {
							return value;
						} else {
							return "@ConstValues.SystemWeb"+"/MeetingMain/Index/"+rec.conferenceNickName;
						}
					}
				},
				{ field: "status", title: "@Resources.Status", align: "center", sortable: true, width: 100 },
				{ field: "isDisplayMobile", title: "@Resources.IsDisplayMobile", align: "center", sortable: true, width: 150 },
				{ field: "isDisplayMobileHome", title: "@Resources.IsDisplayMobileHome", align: "center", sortable: true, width: 170 }
			]]
		});

		$(window).resize(function () {
			$("#dataGrid").datagrid("resize", {
				width: 1200,
				height: $(window).height() - 110
			})
		});

		var pannel = $("#dataGrid").parent().parent().parent();
		if (pannel.attr("class") == "panel datagrid") {
			pannel.css("overflow", "visible");
		}
	});

	function maintenance(id) {
		var url = "@Url.Action(nameof(ConferenceHomeController.HasConferenceRoleBoolean),
				nameof(ConferenceHomeController).GetControllerName())"+ "/" + id;
		$.get(url, null, function (data, textStatus, jqXHR) {
			if (data.result == "@ConstValues.AjaxFailResult") {
				common.showError(data.message);
			} else {
				window.location = "@Url.Action(nameof(ConferenceInfoController.Index),
						nameof(ConferenceInfoController).GetControllerName())" + "/" + id;
			}
		});
	}

	function searchData() {
		$("#dataGrid").datagrid("load", {
			conferenceName: $("#conferenceNameSearch").textbox("getValue")
		});
	}
</script>
}